###### 20 december 2013 kurgan sity russia Coloveov di ###########
#21#22
##############
scl = 7
shag = scl*2
##############
def noten():
	global Fd,Gd,Ad,Bd,C,D,E,F,G,A,B,c,d,e,f,g,a,b
	Fd = pos_y - scl*2	
	Gd = pos_y - scl*1.5
	Ad = pos_y - scl*1
	Bd = pos_y - scl*0.5
	C = pos_y + scl*0
	D = pos_y + scl*0.5
	E = pos_y + scl*1
	F = pos_y + scl*1.5
	G = pos_y + scl*2
	A = pos_y + scl*2.5
	B = pos_y + scl*3
	c = pos_y + scl*3.5
	d = pos_y + scl*4
	e = pos_y + scl*4.5
	f = pos_y + scl*5
	g = pos_y + scl*5.5
	a = pos_y + scl*6
	b = pos_y + scl*6.5
f_o = open("soch1","r")
print "%!PS-Adobe-3.0 EPSF-3.0"
def massr():
	global mass,r_l
	r_l = f_o.readline()
	mass = r_l.split()
cup = 750 + 10
fill = True
dpal = False
dobup = False
vniz = False
trez = False
toch = False
bar = False
fill = True
dobd = False
alter = False
liga = False
single = False
plusp = 0
plusx = 0
plusx1 = 0
plusy = 0
plusy1 = 0
diam = scl/2
def text():
	global r_l,size
	print "/Times-Roman findfont"
	print str(size) +" scalefont"
	print "setfont"
	print "newpath"
	print str(pos_x)+ " " + str(pos_y) + " " + " moveto"
	print "( "+txt+ " ) show"
def circle():
	print "newpath"
        print str(pos_x) + " " + str(pos_y) + " " + str(diam)+" 0 360 arc closepath"
	if fill == True:	
		print "0 0 0 setgray fill"
	print "0.5 setlinewidth"
        print "stroke"	
def line():
	print "newpath"
	print str(pos_x-plusx)+" "+ str(pos_y-plusy) + " moveto"
	print str(pos_x+plusx1)+" "+ str(pos_y+plusy1) + " lineto"
	if single == True:
		print str(x2)+" "+ str(y2) + " moveto"
		print str(x3)+" "+ str(y3) + " lineto"
		print "curveto" 	
	print "0.5 setlinewidth"
	print "stroke"	
#################################################nota###########################################
def obrab():
	global trez,pos_x,shag,plusx,plusx1,plusy,plusy1,vniz,pos_y
	i = 0
	pos_x = 20
	for soch in mass:
		if soch == "||":
			continue
		#######chords
		elif soch[0] == '"':
			chord = soch
			sch = soch.replace('"','')
			chord = sch
			chords()
			continue
		for n in soch:
			if n[i] == "C":
					pos_y = C
					plusx = scl
					plusx1 = scl
					line()		
			elif n[i] == "D":
					pos_y = D
			elif n[i] == "E":
					pos_y = E	
			elif n[i] == "F":	
				if vniz == True:
					pos_y = Fd
					dobd = True
				else:
					pos_y = F			
			elif n[i] == "G":
				if vniz == True:
					notta = Gd
					dobd = True
				else:
					notta = G
			elif n[i] == "A":
				if vniz == True:
					notta = Ad
					dobd = True
				else:
					notta = A
			elif n[i] == "B":
				if vniz == True:
					notta = Bd
					dobd = True
				else:
					notta = B
			elif n[i] == "c":
					notta = c
			elif n[i] == "d":
					notta = d
			elif n[i] == "e":
					notta = e
			elif n[i] == "f":
					notta = f
			elif n[i] == "g":
					notta = g
			elif n[i] == "a":
					notta = a
					dopup = True
			elif n[i] == "[":
					trez = True
					continue
			elif n[i] == "]":
					trez = False
					continue
			elif n[i] == "4":
					fill = False
					continue
			elif n[i] == "6":
					fill = False
					toch = True	
					continue
			elif n[i] == "3":
					fill = True
					toch = True
					circle()
					continue
			elif n[i] == "2":	
					fill = True
					plusx = scl*-0.5
					plusx1 = scl*0.5
					plusy1 = scl*3.5
					line()
					continue
			elif n[i] == "1":
					single = True			
					continue
			elif n[i] == "_" or n[i] == "=" or n[i] == "^" or n[i] == "~":
					alter = True
					alt = n[i]
					continue
			elif n[i] == "u":
				dpal = False
				continue
			elif n[i] == "w":
				dpal = True
				continue
			elif n[i] == ",":
				vniz = True
				dopd = True
				continue
			elif n[i] == "'":
				vniz = False
				dopup = True
				continue
			elif n[i] == "+":
				plusp = plusp + scl/1.5
				continue
			elif n[i] == "-":
				plusp = plusp - scl/1.5
				continue
			elif n[i] == "z":
				pos_x = pos_x + shag/5
				alter = True
				notta = G
				alt = "z"
				continue
			elif n[i] == "|":
				plusx = scl*0
				plusx1 = scl*0
				plusy = scl*0.5
				pos_x = pos_x + shag
				line()
				continue
			elif n[i] == "(":
				plusx = scl*0
				plusy = scl*0.5
				continue
			elif n[i] == ")":
				plusx1 = scl*0
				plusy = scl*0.5
				line()
				continue
			circle()
			if trez == True:
				pos_x = pos_x - shag
			else:
				pos_x = pos_x + shag*2
	i = i + 1
def stan():
	global pos_x,pos_y,plusx,plusx1
	i = 0
	pos_x = 10
	plusx = 0
	plusx1 = 710
	while i < 5:
		line()
		pos_y = pos_y - scl
		i = i + 1
	plusx = 0
def obs():	
	massr()
	if len(r_l) > 0:
		stan()
		noten()
		obrab()
	else:
		pass
pos_y = 100 * scl
obs()
pos_y = 85 * scl
obs()
pos_y = 70 * scl
obs()
pos_y = 55 * scl
obs()
pos_y = 40 * scl
obs()
pos_y = 25 * scl
obs()
pos_y = 10 * scl
obs()
f_o.close()
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
print "% ###################### OK #########################"
